package emulator.hardware.io.peripherals.iec;

import java.util.LinkedList;
import java.util.Observable;

public class IecLog extends Observable {

	private static int max_buf = 200;
	private LinkedList<String> log = new LinkedList<String>();
	
	public synchronized void writeln(String text)
	{
		log.add(text+"\n");
		if (log.size() > max_buf)
			log.pop();
		setChanged();
		if (log.size() == 1)
			notifyObservers();
	}

	public synchronized String getLogLine()
	{
		if (log.isEmpty())
			return null;
		return log.pop();
	}
}
